<template>
	<!-- 我的核销 -->
	<view class="myCancel">
		<view class="canbOX">
			<span class="canTitle">姓名</span>
			<view class="canBody">{{userObj.nickname}}</view>
		</view>
		<view class="canbOX">
			<span class="canTitle">性别</span>
			<view class="canBody">{{userObj.gender == 1 ? "男性" : '女性'}}</view>
		</view>
		<view class="canbOX">
			<span class="canTitle">手机号</span>
			<view class="canBody">{{userObj.phone == 200 ? '无' : userObj.phone}}</view>
		</view>
		<view class="canbOX">
			<span class="canTitle">公司</span>
			<view class="canBody">{{userObj.company  || '无'}}</view>
		</view>
		
		<view class="canbOX">
			<span class="canTitle">职业</span>
			<view class="canBody">{{userObj.post || '无'}}</view>
		</view>
		<view class="canbOX">
			<span class="canTitle">所在区域</span>
			<view class="canBodyx">{{userObj.address}}</view>
		</view>
		<view class="butBox" @click="buttons">确认核销</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
              type : null,
			  orderNo : "",
			  userObj : {}
			}
		},
		onLoad(params) {
			// debugger
			// if(params.type != "null"){
				// debugger
				this.type = params.type;
			// }
		      
			  // debugger
			  this.orderNo = params.orderNo;
			  // this.buttons();
			  this.init();
		},
		methods:{
			init(){
				if(this.type == "activity"){
					// 获取核销的特权卡详情
					this.$apis.userActivityWriteOffInfo( this.orderNo).then(res=>{
						// debugger
						if(res.code == 200){
						this.users(res)
						}
					})
					
					
				}else{
					// debugger
					// 获取核销的活动详情
					this.$apis.userActivitywriteOffInfoPayNo( this.orderNo).then(res=>{
						if(res.code == 200){
							// debugger
							this.users(res);
						}
					})
					
				}
				
			},
			buttons(){
				if(this.type == "activity"){
					// debugger
					this.activity();
				}else{
					
					this.privilege();
					
				}
			},
			users(res){
				this.userObj = {};
				this.userObj= res.data.user
			},
			activity(){
				this.$apis.userActivityWriteOff( this.orderNo
				).then(res => {
					// debugger
					console.log('200=====>', res)
					if (res.code == 200) {
						uni.showToast({
							title: "操作成功",
							duration: 2500
						})
						setTimeout(()=>{
							uni.navigateBack()
						},1500)
					} else {
						uni.showToast({
							title: "该状态无法审核",
							icon: "none",
							duration: 2500
						})
					}
								
								
				});
			},
			privilege(){
				this.$apis.userActivityWriteOffPayNo(
					this.orderNo
				).then(res => {
								
					console.log('200=====>', res)
					if (res.code == 200) {
						uni.showToast({
							title: "操作成功",
							duration: 2500
						})
						setTimeout(()=>{
							uni.navigateBack()
						},1500)
					} else {
						uni.showToast({
							title: "该状态无法审核",
							icon: "none",
							duration: 2500
						})
					}
								
				});
			}
		}
	}
</script>

<style lang="scss">
	.myCancel{
		width: 100%;
		height: 100vh;
		box-sizing: border-box;
		padding: 0 40rpx;
		.canbOX{
			display: flex;
			    margin: 50rpx 0;
		}
		.canBodyx{
			font-size: 30rpx;
			font-family: Source Han Sans CN, Source Han Sans CN-Regular;
			font-weight: 400;
			text-align: JUSTIFIED;
			color: #2d3034;
			  
		}
		
		.canTitle{
			font-size: 30rpx;
			font-family: Source Han Sans CN, Source Han Sans CN-Bold;
			font-weight: 700;
			text-align: JUSTIFIED;
			color: #2d3034;
			display: inline-block;
			    flex: 0 0 180rpx;
		}
		.butBox{
			width: calc(100% - 80rpx);
			height: 84rpx;
			line-height: 84rpx;
			opacity: 1;
			background: #f10200;
			border-radius: 12rpx;
			color: #fff;
			font-weight: 700;
			    text-align: center;
				position: fixed;
				bottom: 100rpx;
		}
	}
</style>
